//
//  AppendPostponeTableViewCell.m
//  YuTang
//
//  Created by 葛悦彣 on 2025/3/11.
//

#import "AppendPostponeTableViewCell.h"

@interface AppendPostponeTableViewCell ()

@property (nonatomic ,strong) UILabel * sortlab;
@property (nonatomic ,strong) UILabel * jxcreateTimeLab;
@property (nonatomic ,strong) UILabel * jxuserRealNameLab;
@property (nonatomic ,strong) UILabel * yqcreateTimeLab;
@property (nonatomic ,strong) UILabel * yquserRealNameLab;
@property (nonatomic ,strong) UIView * line;

@property (nonatomic ,strong) UILabel * toplab;
@end

@implementation AppendPostponeTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
    self.contentView.clipsToBounds = YES;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    self.clipsToBounds = YES;
    
    
    UIView * makeview = [UIView new];
    makeview.clipsToBounds = YES;
    makeview.addYJ(kwt(7));
    makeview.backgroundColor = UIColor.whiteColor;
    [self.contentView addSubview:makeview];
    [makeview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(8));
        make.right.offset(kwt(-8));
        make.top.offset(kwt(10));
        make.bottom.offset(0);
    }];
    
    UIImageView * img = kimageView(@"extension_bg");
    [makeview addSubview:img];
    [img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.offset(0);
        make.height.offset(kwt(44));
    }];
    
    UILabel * sortlab = [DTKTool labelWithText:@"第1次延期" andFont:kCFont(19) andTextColor:KcolorHex(@"#121212")];
    self.sortlab = sortlab;
    [img addSubview:sortlab];
    [sortlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(10));
        make.centerY.offset(0);
    }];
    
    
    UIView * backview = [UIView new];
    [DTKTool YJBK:kwt(7) andView:backview andWidth:0.5 andColor:KcolorHex(@"#F0F3F5")];
    backview.backgroundColor = KcolorHex(@"#F7FAFF");
    [makeview addSubview:backview];
    [backview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(10));
        make.right.offset(kwt(-10));
        make.top.equalTo(img.mas_bottom);
        make.bottom.offset(kwt(-10));
    }];
    
    ///继续下发
    UIView * wyview1 = [UIView new];
    [DTKTool YJBK:kwt(6) andView:wyview1 andWidth:kwt(1) andColor:KcolorHex(@"#0967FF")];
    [backview addSubview:wyview1];
    [wyview1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(6));
        make.top.offset(kwt(15));
        make.width.height.offset(kwt(12));
    }];
    UIView * nyview1 = [UIView new];
    nyview1.backgroundColor = KcolorHex(@"#0967FF");
    nyview1.addYJ(kwt(3.5));
    [wyview1 addSubview:nyview1];
    [nyview1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.offset(0);
        make.width.height.offset(kwt(7));
    }];

    UILabel * lab1 = [DTKTool labelWithText:@"继续下发：" andFont:kFont(15) andTextColor:KcolorHex(@"#535353")];
    self.toplab = lab1;
    [backview addSubview:lab1];
    [lab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(22));
        make.top.offset(kwt(14));
        make.height.offset(kwt(15));
    }];
    
    UILabel * jxcreateTimeLab = [DTKTool labelWithText:@"-" andFont:kFont(15) andTextColor:KcolorHex(@"#0967FF")];
    self.jxcreateTimeLab = jxcreateTimeLab;
    [backview addSubview:jxcreateTimeLab];
    [jxcreateTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lab1.mas_right);
        make.centerY.equalTo(lab1);
        make.height.offset(kwt(15));
    }];
    
    
    
    UILabel * lab2 = [DTKTool labelWithText:@"操作人：" andFont:kFont(15) andTextColor:KcolorHex(@"#535353")];
    [backview addSubview:lab2];
    [lab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lab1);
        make.top.offset(kwt(38));
        make.height.offset(kwt(15));
    }];
    
    
    UILabel * jxuserRealNameLab = [DTKTool labelWithText:@"-" andFont:kFont(15) andTextColor:KcolorHex(@"#535353")];
    self.jxuserRealNameLab = jxuserRealNameLab;
    [backview addSubview:jxuserRealNameLab];
    [jxuserRealNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lab2.mas_right);
        make.centerY.equalTo(lab2);
        make.height.offset(kwt(15));
    }];
    
    UIView * yqview = [UIView new];
    yqview.backgroundColor = KcolorHex(@"#F7FAFF");
    [backview addSubview:yqview];
    [yqview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.offset(0);
        make.height.offset(kwt(65));
    }];
    
    ///继续下发
    UIView * wyview2 = [UIView new];
    [DTKTool YJBK:kwt(6) andView:wyview2 andWidth:kwt(1) andColor:KcolorHex(@"#0967FF")];
    [yqview addSubview:wyview2];
    [wyview2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(6));
        make.top.offset(kwt(15));
        make.width.height.offset(kwt(12));
    }];
    UIView * nyview2 = [UIView new];
    nyview2.backgroundColor = KcolorHex(@"#0967FF");
    nyview2.addYJ(kwt(3.5));
    [wyview2 addSubview:nyview2];
    [nyview2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.offset(0);
        make.width.height.offset(kwt(7));
    }];
    
    UILabel * lab3 = [DTKTool labelWithText:@"延期下发：" andFont:kFont(15) andTextColor:KcolorHex(@"#535353")];
    [yqview addSubview:lab3];
    [lab3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(22));
        make.top.offset(kwt(14));
        make.height.offset(kwt(15));
    }];
    
    UILabel * yqcreateTimeLab = [DTKTool labelWithText:@"-" andFont:kFont(15) andTextColor:KcolorHex(@"#0967FF")];
    self.yqcreateTimeLab = yqcreateTimeLab;
    [yqview addSubview:yqcreateTimeLab];
    [yqcreateTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lab3.mas_right);
        make.centerY.equalTo(lab3);
        make.height.offset(kwt(15));
    }];
    
    
    
    UILabel * lab4 = [DTKTool labelWithText:@"操作人：" andFont:kFont(15) andTextColor:KcolorHex(@"#535353")];
    [yqview addSubview:lab4];
    [lab4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lab3);
        make.top.offset(kwt(38));
        make.height.offset(kwt(15));
    }];
    
    
    UILabel * yquserRealNameLab = [DTKTool labelWithText:@"-" andFont:kFont(15) andTextColor:KcolorHex(@"#535353")];
    self.yquserRealNameLab = yquserRealNameLab;
    [yqview addSubview:yquserRealNameLab];
    [yquserRealNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lab4.mas_right);
        make.centerY.equalTo(lab4);
        make.height.offset(kwt(15));
    }];
    
    UIView * line = [UIView new];
    self.line = line;
    line.backgroundColor = KcolorHex(@"#0967FF");
    [backview addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(wyview1);
        make.width.offset(1);
        make.top.offset(kwt(30));
        make.height.offset(kwt(27));
    }];
    
}

- (void)setModel:(AppendPostponeModel *)model{
    _model = model;
    self.sortlab.text = [NSString stringWithFormat:@"第%lu次延期",model.sort];
  
    self.yqcreateTimeLab.text = model.createTime;
    self.yquserRealNameLab.text = model.userRealName;
    if(model.pondPostponeRecordModel){
        if(model.pondPostponeRecordModel.type == 2){
            self.toplab.text = @"继续下发：";
            self.jxcreateTimeLab.text = model.pondPostponeRecordModel.createTime;
            self.jxuserRealNameLab.text = model.pondPostponeRecordModel.userRealName;
            [self.line mas_updateConstraints:^(MASConstraintMaker *make) {
                make.height.offset(kwt(46));
            }];
        } else if(model.pondPostponeRecordModel.type == 3){
            self.toplab.text = @"延期中断：";
            self.jxcreateTimeLab.text = model.pondPostponeRecordModel.createTime;
            self.jxuserRealNameLab.text = model.pondPostponeRecordModel.userRealName;
            [self.line mas_updateConstraints:^(MASConstraintMaker *make) {
                make.height.offset(kwt(46));
            }];
        }
    } else  {
        [self.line mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.offset(kwt(27));
        }];
    }
    
}

@end
